package com.crack.nga2.custom;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * 配合DragGridView 在拖拽item的时候禁止ViewPager滑动
 * Created by Administrator on 2016/1/21.
 */
public class MyViewPager extends ViewPager {
    public MyViewPager(Context context) {
        super(context);
    }

    public MyViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    private boolean scrollSwitch = true;

    public void setScrollWitch(boolean scrollSwitch) {
        this.scrollSwitch = scrollSwitch;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if(!scrollSwitch)
            return false;
        return super.onTouchEvent(ev);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if(!scrollSwitch)
            return false;
        return super.onInterceptTouchEvent(ev);
    }
}
